import React from 'react';
import { connect } from 'react-redux';
import actions from '../../store/actions/action';


class SearchBox extends React.Component {
    render() {
        return <div className="inputBox">
            <input type="text" ref='inp' onKeyDown={
                ev => {
                    if (ev.keyCode === 13) {
                        this.searchHandle();
                    }
                }
            } />
            <a className='searchLink' title='搜索' onClick={
                ev => {
                    this.searchHandle();
                }
            }></a>
        </div>
    }
    searchHandle() {
        let val = this.refs.inp.value;
        if (!val) return;
        this.props.querySearchList({ val, type: 1 });
    }
}


export default connect(state => state.search, actions.search)(SearchBox);